//
// Created by xili on 2024/9/2 18:38.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int maxCount(vector<int> &banned, int n, int maxSum) {
        unordered_set<int> us(banned.begin(), banned.end());
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (!us.count(i) && maxSum - i >= 0) {
                ans++;
                maxSum -= i;
            }
        }
        return ans;
    }
};